#!/usr/bin/python

# Check the three erase modes (ESC [ 0/1/2 J).
# Check also default parameter value (ESC [ J).
# This should run identically on Windows and Unix.

import sys
import fixpath
from colorama import init, Fore, Back, Style

init()

def at(y, x, s=""):
   sys.stdout.write("\x1b[%s;%sH%s" % (y+1, x+1, s))
   sys.stdout.flush()


def erase(mode):
   sys.stdout.write("\x1b[%sJ" % mode)

# Full screen in green
sys.stdout.write(Back.GREEN)
erase(2)

# Beginning of screen in red
at(3, 10)
sys.stdout.write(Back.RED)
erase(1)

# End of screen in blue
at(16, 30)
sys.stdout.write(Back.BLUE)
erase(0)

# Very end of screen in yellow
at(22, 40)
sys.stdout.write(Back.YELLOW)
erase("") # Check default parameter value

# Add some text
sys.stdout.write(Back.RESET)
at(4, 10, "^")
at(5, 10, "|")
at(6, 10, "Red should end here")

at(9, 10, "Middle should be green")

at(15, 30, "v")
at(14, 30, "|")
at(13, 30, "Blue should start here")

at(21, 40, "v")
at(20, 40, "|")
at(19, 40, "Yellow should start here")

# Position for prompt
at(11, 0)
